﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<LegalDocumentInputModels>" %>

<%@ Import Namespace="SDT.Lib.Helpers" %>
<%@ Import Namespace="SDT.Admin.ViewModels" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Thêm văn bản chính sách
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%if (ViewData["MessageInfo"] == null)
      { %>
    <% using (Html.BeginForm("Create", "LegalDocument", FormMethod.Post, new
       {
           id = "adminForm",
           enctype = "multipart/form-data"
       }))
       {%>
    <%= Html.ValidationSummary(true)%>
    <table class="admintable" width="100%">
        <tbody>
            <tr>
                <td class="key">Số hiệu</td>
                <td><%=Html.TextBox("LegalNumber", null, new { style = "width: 500px;", @class = "required" })%></td>
            </tr>
            <tr>
                <td class="key">
                    Cơ quan ban hành (<font color="red">*</font>)
                </td>
                <td>
                    <%=Html.DropDownList("Publisher",new SelectList(Model.LegPublisherDefault,"Key","Value").ToList(),"--Chọn cơ quan ban hành--")%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Cơ quan đồng ban hành
                </td>
                <td>
                    <%=Html.DropDownList("SeconPublisher", new SelectList(Model.LegPublisherDefault, "Key", "Value").ToList(), "--Chọn cơ quan đồng ban hành--")%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Loại văn bản (<font color="red">*</font>)
                </td>
                <td>
                    <%=Html.DropDownList("CatID", new SelectList(Model.LegCategoryDefault, "Key", "Value").ToList(), "--Chọn loại văn bản--", new { @class="rquired" })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Người ký (<font color="red">*</font>)
                </td>
                <td>
                    <%=Html.TextBox("Singer", null, new { @class="required"})%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Ngày ban hành (<font color="red">*</font>)
                </td>
                <td>
                    <%=Html.TextBox("PublishDate", DateTime.Now, new { style = "width: 150px;", @class = "datepicker" })%>
                    <%--<img id="jqueryDatepicker" class="ui-datepicker-trigger" src="/Images/calendar.gif" alt="" title="">--%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    Thời gian bắt đầu hiệu lực (<font color="red">*</font>)
                </td>
                <td>
                    <%=Html.TextBox("StartDate", DateTime.Now, new { style = "width: 150px;", @class = "datepicker" })%>
                    <%--<img id="Img1" class="ui-datepicker-trigger" src="/Images/calendar.gif" alt="" title="">--%>
                </td>
            </tr>
             <tr>
                <td class="key">
                    Trích yếu nội dung
                </td>
                <td>
                    <%=Html.TextArea("LegalDocumentNote",null, new { cols = 90, rows = 16 })%>
                </td>
            </tr>
            <tr>
                <td class="key">
                    File tài liệu
                </td>
                <td>
                    <table id="frmFile" width="100%" class="adminlist">
                        <tr>
                            <th>
                                Tên tài liệu
                            </th>
                            <th>
                                Mô tả
                            </th>
                            <th>
                                Tài liệu đính kèm:
                            </th>
                        </tr>
                        <tr>
                            <td>
                                <input id="fileName1" name="fileName1" type="text" />
                            </td>
                            <td>
                                <input id="description1" name="description1" type="text" />
                            </td>
                            <td>
                                <input id="fileInput1" size="25" name="fileInput1" type="file" onchange="check_extension(this.value,'btnSave');" />
                                &nbsp;<input id="btnAddFile" type="button" value="Thêm" onclick="AddFile();" />
                            </td>
                        </tr>
                    </table>

                    <script type="text/javascript">
                        var fileIndex = 1;
                        var hash = { '.jpg': 1, '.png': 1, '.gif': 1, '.doc': 1, '.docx': 1, '.xls': 1, '.xlsx': 1, '.zip': 1, '.rar': 1, '.ppt': 1, '.pptx': 1, '.txt:': 1 };
                        function check_extension(filename, submitId) {
                            var re = /\..+$/;
                            var ext = filename.match(re).toString().toLowerCase();
                            var submitEl = document.getElementById(submitId);
                            if (hash[ext]) {
                                submitEl.disabled = false;
                                return true;
                            } else {
                            }
                        };
                        function AddFile() {
                            fileIndex++;
                            var tag = "<td><input id='fileName" + fileIndex.toString() + "' name='fileName" + fileIndex.toString() + "' type=\"Text\" /></td>" +
	                         "<td><input id='description" + fileIndex.toString() + "' name='description" + fileIndex.toString() + "' type=\"Text\" /></td>" +
	                        "<td><input id='fileInput" + fileIndex.toString() + "' name='fileInput" + fileIndex.toString() + "' type=\"file\" size='25'  onchange=\"check_extension(this.value,'btnSave');\" /></td>";
                            var row = "<tr>" + tag + "</tr>";
                            $("#frmFile").append(row);
                        };
                    </script>

                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <input type="hidden" id="AddDate" name="AddDate" value="<%= DateTime.Now %>" />
                    <input type="submit" id="btnSave" value="Thêm mới" onclick="return check_extension('ArticleImage','btnSave');" />
                </td>
            </tr>
        </tbody>
    </table>
    <%}
      } %>

    <script type="text/javascript">
        $(document).ready(function() {
            $("#adminForm").validate();
            $(".datepicker").datepicker({
                dateFormat: "dd/mm/yy",
                changeMonth: true,
                showOn: "button",
                buttonImage: "/Images/calendar.gif",
                buttonImageOnly: true,
                changeYear: true
            });
        });

        var fileIndex = 1;
        var hash = { '.jpg': 1, '.png': 1, '.gif': 1, '.doc': 1, '.docx': 1, '.xls': 1, '.xlsx': 1, '.zip': 1, '.rar': 1, '.ppt': 1, '.pptx': 1, '.txt:': 1 };
        function check_extension(filename, submitId) {
            var re = /\..+$/;
            var ext = filename.match(re).toString().toLowerCase();
            var submitEl = document.getElementById(submitId);
            if (hash[ext]) {
                submitEl.disabled = false;
                return true;
            } else {
            }
        }
        tinyMCE.init({
            mode: "exact",
            elements: "LegalDocumentContent,LegalDocumentNote",
            theme: "advanced",
            plugins: "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,paste,imagemanager",
            theme_advanced_buttons1: "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
            theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,cleanup,help,code,|,insertdate,inserttime,preview",
            theme_advanced_toolbar_location: "top",
            theme_advanced_toolbar_align: "left",
            theme_advanced_statusbar_location: "bottom",
            paste_use_dialog: false,
            paste_auto_cleanup_on_paste: true,
            paste_convert_headers_to_strong: false,
            paste_strip_class_attributes: "all",
            paste_remove_spans: true,
            paste_remove_styles: true
        });
    </script>

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Toolbar" runat="server">
    <td>
        <%= Html.Toolbar("Quay về", "/LegalDocument", "back")%>
    </td>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Header" runat="server">
    Thêm văn bản
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Message" runat="server">
    <%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>
</asp:Content>
